﻿using System.AddIn.Pipeline;
using RootfusHostView;
using RootfusAddinContracts;
using System;


namespace RootfusAddinHostAdapters
{
    [HostAdapter]
    class PinDefinitionContractToHostViewAdapter : PinDefinition
    {
        private IPinDefinitionContract _contract;
        private ContractHandle _handle;

        public PinDefinitionContractToHostViewAdapter(IPinDefinitionContract contract)
        {
            _contract = contract;
            _handle = new ContractHandle(_contract);
        }

        public override string Name
        {
            get { return _contract.Name; }
        }

        public IPinDefinitionContract GetSourceContract()
        {
            return _contract;
        }

        #region PinDefinition Members


        public override RootfusHostView.PinConnectionType ConnectionType
        {
            get
            {
                switch (_contract.ConnectionType)
                {
                    case RootfusAddinContracts.PinConnectionType.PinInfinite:
                        return RootfusHostView.PinConnectionType.PinInfinite;
                    case RootfusAddinContracts.PinConnectionType.PinSingle:
                        return RootfusHostView.PinConnectionType.PinSingle;
                    default:
                        throw new Exception("Not Implemented!");
                }
            }
        }

        #endregion
    }
}
